package com.baosight.sczx.zm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.cf.domain.ZMCFMessageLog;
import com.baosight.sczx.zm.domain.ZM91;

/**
 * 
 * <p>Title: ServiceZM96.java</p>
 * <p>Description: 工作联系单类</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author bobswang
 * @version 1.0
 * <pre>Histroy:
 *          2012-11-15 下午04:03:22  高强  Create
 *</pre>
 */
public class ServiceZM96 extends ServiceEPBase
{
	public EiInfo initLoad(EiInfo inInfo)
	{
		EiInfo outInfo = queryMessage(inInfo);
		return outInfo;
	}
	/**
	 * 
	 * <p>Function: queryMessage</p>
	 * <p>Description: 查询消息信息</p>
	 * <p>return value:EiInfo</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-11-15 下午04:03:22  高强  Create
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	private EiInfo queryMessage(EiInfo inInfo) {
		String fdUserId = UserSession.getUserId() == null ? "" : UserSession.getUserId().toString();//登陆人ID
		StaticTools.setQueryParameters(inInfo, "fdStatus", 0, true);//添加查询条件
		StaticTools.setQueryParameters(inInfo, "fdUserId", fdUserId, true);//添加查询条件
		EiBlock inBlock = new EiBlock(EiConstant.resultBlock);
		Map inMap = new HashMap();
		inMap.put("limit", 20);
		inBlock.setAttr(inMap);
		inInfo.addBlock(inBlock);
		EiInfo outInfo = super.query(inInfo, "ZMCFMessageLog.query", new ZMCFMessageLog());
		
		return outInfo;
	}
	/**
	 * 
	 * <p>Function: query</p>
	 * <p>Description: 查询消息信息</p>
	 * <p>return value:EiInfo</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-11-15 下午04:03:22  高强  Create
	 * </p>
	 *
	 */
	public EiInfo query(EiInfo inInfo) 
	{
		EiInfo outInfo = queryMessage(inInfo);
		
		return outInfo;
	}
	
	public EiInfo update(EiInfo inInfo) 
	{
		inInfo.getBlock(EiConstant.resultBlock).setCell(0, "fdStatus", "1");
		inInfo.getBlock(EiConstant.resultBlock).setCell(0, "fdReadTime", StaticTools.getDateTime());
		EiInfo outInfo = super.update(inInfo, "ZMCFMessageLog.updateStatus");
		outInfo.set("fdFrontPage", inInfo.get("fdFrontPage"));
		return outInfo;
	}
	
}
